﻿@helper Build(int pid)
{
    var tmp = Model as IEnumerable<dynamic>;
    var cat = pid == 0 
        ? tmp.FirstOrDefault(x => x.Parent == null)
        : tmp.FirstOrDefault(x => x.Parent != null && JDM.Int32(x.Parent.EntityID) == pid);
    if(cat != null)
    {
        var t_cat = (cat.Translations as IEnumerable<dynamic>)
            .SingleOrDefault(x => JDM.Int32(x.Language.EntityID) ==
                JDM.Int32(Svc.Localization.Language.EntityID));
        <span class="separator">/</span>
        <a href="@Url.Action(Loc.Act("Index").Set(new
        {
            categoryID = JDM.Int32(cat.EntityID)
        }).Localized())">@(t_cat != null ? JDM.String(t_cat.Name) : JDM.String(cat.EntityID))</a>
        @Build(JDM.Int32(cat.EntityID))
    }
}
@Build(0)